USE Liberty
GO

---------------------------------------------------------------------------------------------------
----MilitaryRanks
---------------------------------------------------------------------------------------------------
SET NOCOUNT OFF
SET ANSI_NULLS ON
SET ANSI_PADDING ON
SET ANSI_WARNINGS ON
SET ARITHABORT ON
SET CONCAT_NULL_YIELDS_NULL ON
SET QUOTED_IDENTIFIER ON
SET NUMERIC_ROUNDABORT OFF
GO

PRINT 'Creating Table MilitaryRanks...'
GO

IF OBJECT_ID( 'MilitaryRanks' ) IS NULL
BEGIN
	CREATE TABLE dbo.MilitaryRanks
	(OID					bigint		IDENTITY(1, 1)	NOT NULL
	,Version				rowversion
	,BranchOfServiceID		bigint						NOT NULL
	,RankStructure			varchar(30)					NOT NULL
	,Rank					varchar(50)					NOT NULL
	,PayGrade				varchar(05)					NOT NULL
	,Abbreviation			varchar(10)					NOT NULL
	,Active					tinyint						NOT NULL 
		CONSTRAINT DFLT_MilitaryRanks_Active DEFAULT (1)
	,DisplayOrder		smallint						NOT NULL 
	    CONSTRAINT DFLT_MilitaryRanks_DisplayOrder DEFAULT (1)
	,CreatedDate				datetime					NOT NULL
		CONSTRAINT DFLT_MilitaryRanks_CreatedDate DEFAULT GETDATE()

	,CONSTRAINT PK_MilitaryRanks PRIMARY KEY CLUSTERED( OID ) --ON PRIMARY

	,CONSTRAINT FK_MilitaryRanks_TypesOfMilitaryBranch FOREIGN KEY (BranchOfServiceID)
		REFERENCES TypesOfMilitaryBranch(OID)
		)

		PRINT 'Table MilitaryRanks has been created successfully.'
END
ELSE 
BEGIN
    PRINT 'Table MilitaryRanks already exists.'
END

GO

--drop table dbo.MilitaryRanks
